package b3.widget.basic
{
	import b3.util.*;
	
	import flash.display.Sprite;
	import flash.text.*;
	import flash.filters.*;

	public class LoadProgressBar extends Sprite
	{
		private var progressBar:MaskProgressBar;
		private var progressText:TextField;
		
		public function LoadProgressBar(percentage:Number = 0)
		{
			super();
			//进度条
			progressBar = new MaskProgressBar(CProgressBar, CProgressBarFrame);
			progressBar.percentage = percentage;
			addChild(progressBar);
			//文字
			progressText = new TextField();
        	progressText.autoSize = TextFieldAutoSize.CENTER;
			progressText.defaultTextFormat = new TextFormat("微软雅黑", 22, 0x0088FF);
			progressText.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			progressText.selectable = false;
			progressText.text = "00%";
			progressText.x = (progressBar.width - progressText.width) / 2;
			progressText.y = 75;
			addChild(progressText);
			updateProgress(percentage);
		}
		
		public function updateProgress(percentage:Number):void
		{
			progressBar.percentage = percentage;
			var percentage100:int = percentage * 100;
			progressText.text = percentage100.toString() + "%";
		}
	}
}